package ar.edu.unq.tpi.constriu.c1.tejeda.Dominio.Agenda;

import java.util.Date;

import org.uqbar.commons.model.Entity;
import org.uqbar.commons.model.UserException;


@SuppressWarnings("serial")
public class Contact extends Entity{

	
	/**
	 * @param args
	 */
	
	public String name;
	public String phoneNumber;
	public String mail;
	public Date birthDate;
	public String observations;
	public City city;
	public static final String NAME = "name";
	public static final String PHONENUMBER = "phoneNumber";
	public static final String MAIL = "mail";
	public static final String BIRTHDATE = "birthDate";
	public static final String OBSERVATIONS = "observations";
	public static final String CITY = "city";
		
	
	
	public Contact() {
		super();
	}

	public Contact(String name, String phoneNumber, String mail,
			Date birthDate, String observations, City ciudad) {
		super();
		this.name = name;
		this.phoneNumber = phoneNumber;
		this.mail = mail;
		this.birthDate = birthDate;
		this.observations = observations;
		this.city = ciudad;
		if (name.isEmpty() && mail.isEmpty()){
			throw new UserException("Nombre y mail no pueden ser vacíos");
		}
		
	}

	public String getMail() {
		
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;		
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		if (birthDate == null) {
			throw new UserException("Ingrese una fecha válida");
		}
		this.birthDate = birthDate;
	}

	public String getObservations() {
		return observations;
		
	}

	public void setObservations(String observations) {
		this.observations = observations;
	}

	public City getCity() {
		return city;
	}
	
	public void setCity(City ciudad) {
		this.city = ciudad;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}


	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	

	// *************************************
	// ** Validaciones
	// *************************************

	@Override
	public void validateCreate() {
		if (this.getName() == null) {
			throw new UserException("Falta asignar un nombre al contacto");
		}
		if (this.getMail() == null) {
			throw new UserException("Falta asignar una dirección de mail al contacto");
		}
	}

	
	
	
	public enum City {
		QUILMES("Quilmes"),
		BERNAL("Bernal"),
		BERAZATEGUI("Berazategui"),
		AVELLANEDA("Avellaneda");
		
		private String nombre;
		
		private City(String nombre) {
			this.nombre = nombre;
		}
		
		public String getNombre() {
			return this.nombre;
		}
	}

}
